package TestDemo;

public class Main {

    /*public ListNode removeElements(ListNode head, int val) {
        if (head == null) return null;
        ListNode cur = head;
        while (cur != null && cur.next != null){
            if (cur.next.val == val){
                ListNode t = cur.next.next;
                cur.next.next = null;
                cur.next = t;
            } else {
                cur = cur.next;
            }
        }
        if (head.val == val){
            cur = head.next;
            head.next = null;
            head = cur;
        }
        return head;
    }*/

    /*public ListNode reverseList(ListNode head) {
        if (head == null) return null;
        ListNode cur = head;
        ListNode t = null;
        while (cur != null && cur.next != null){
            ListNode nextNode = cur.next;
            cur.next = t;
            t = cur;
            cur = nextNode;
        }
        cur.next = t;
        head = cur;
        return head;
    }*/

    /*public ListNode middleNode(ListNode head) {
        ListNode slow = head;
        ListNode fast = head;
        while (fast != null && fast.next != null){
            slow = slow.next;
            fast = fast.next.next;
        }
        return slow;
    }*/

    /*public class Solution {
        public ListNode FindKthToTail(ListNode head,int k) {
            ListNode slow = head;
            ListNode fast = head;
            while (k != 0 && fast != null){
                fast = fast.next;
                k--;
            }
            if (k != 0){
                return null;
            }
            while (fast != null){
                fast = fast.next;
                slow = slow.next;
            }
            return slow;
        }
    }*/

    public static void main(String[] args) {
        SingleLinkedList singleLinkedList = new SingleLinkedList();
        singleLinkedList.addFirst(3);
        singleLinkedList.addFirst(2);
        singleLinkedList.addFirst(1);
        singleLinkedList.addLast(4);
        singleLinkedList.addLast(5);
        singleLinkedList.addLast(6);
        singleLinkedList.addLast(6);
        singleLinkedList.addIndex(0,1);
        singleLinkedList.addIndex(1,4);
        singleLinkedList.addIndex(9,10);
        singleLinkedList.display();
        //System.out.println(singleLinkedList.contains(1));
        singleLinkedList.removeAllKey(6);
        singleLinkedList.display();
        System.out.println("haha");
    }
}
